import { request } from '@/utils/request';
import type {  TenpayPrepayOrder,TenpayPrepayModel,AlipayPrepayOrder} from '@/api/model/testModel';
//import {PageData} from '@/api/model/pageModel'

const Api = {
  TenpayTest: '/test/tenpay', //微信支付测试
  TenpayJsapi:'/tenpay/jsapi',
  AlipayTest:'/test/alipay',//支付宝预支付订单
  AlipayPagePayUrl:'/alipay/pagepay',
  AlipayWapPayUrl:'/alipay/wappay',
  AlipayTradeQuery:'/alipay/trade/query' //查询订单
};

//微信支付测试数据
export function TenpayPrepayOrder(amount:any) {
  return request.get<TenpayPrepayOrder>({
      url: Api.TenpayTest+'?amount='+amount
    });
}
//微信预支付
export function TenpayJSAPIprepay(data:any){
  return request.post<TenpayPrepayModel>({
    url:Api.TenpayJsapi,
    data:data
  });
}

//支付宝订单
export function AlipayPrepayOrder(amount:any){
  return request.get<AlipayPrepayOrder>({
    url:Api.AlipayTest+'?amount='+amount
  })
}

//支付宝PC端支付
export function AlipayPagePay(prepayInfo:any){
  return request.get({
    url:Api.AlipayPagePayUrl+"?orderNo="+prepayInfo.orderNo+'&orderName='+prepayInfo.orderName+'&payAmount='+prepayInfo.payAmount+'&attach='+prepayInfo.attach+'&returnUrl='+prepayInfo.returnUrl
  })
}
//移动端支付
export function AlipayWapPay(prepayInfo:any){
  return request.post({
    url:Api.AlipayWapPayUrl,
    data: prepayInfo
  })
}

export function AlipayTradeQuery(orderNo:string,tradeNo:string)
{
  return request.get({
    url:Api.AlipayTradeQuery+'?orderNo='+orderNo+'&tradeNo='+tradeNo
  })
}
